<!--
Copyright (C) 2023 Nicola Murino

This WebUI uses the KeenThemes Mega Bundle, a proprietary theme:

https://keenthemes.com/products/templates-mega-bundle

KeenThemes HTML/CSS/JS components are allowed for use only within the
SFTPGo product and restricted to be used in a resealable HTML template
that can compete with KeenThemes products anyhow.

This WebUI is allowed for use only within the SFTPGo product and
therefore cannot be used in derivative works/products without an
explicit grant from the SFTPGo Team (support@sftpgo.com).
-->
{{- define "errmsg"}}
<div id="errorMsg" class="{{if not . }}d-none {{end}}rounded border-warning border border-dashed bg-light-warning d-flex align-items-center p-5 mb-10">
    <i class="ki-duotone ki-information-5 fs-3x text-warning me-5">
        <span class="path1"></span>
        <span class="path2"></span>
        <span class="path3"></span>
    </i>
    <div class="text-gray-800 fw-bold fs-5 d-flex flex-column pe-0 pe-sm-10">
		<span {{if .}}data-i18n="{{.Message}}" {{if .HasArgs}}data-i18n-options="{{.Args}}"{{end}}{{end}} id="errorTxt"></span>
	</div>
    <button id="id_dismiss_error_msg" type="button" class="position-absolute position-sm-relative m-2 m-sm-0 top-0 end-0 btn btn-icon btn-sm btn-active-light-primary ms-sm-auto">
        <i class="ki-solid ki-cross fs-2x text-gray-700"></i>
    </button>
</div>
{{- end}}

{{- define "theme-setup"}}
<script type="text/javascript" {{- if .}} nonce="{{.}}"{{- end}}>
    var defaultThemeMode = "system";
    var themeMode;
	if ( document.documentElement ) {
		if ( document.documentElement.hasAttribute("data-bs-theme-mode")) {
			themeMode = document.documentElement.getAttribute("data-bs-theme-mode");
		} else {
			if ( localStorage.getItem("data-bs-theme") !== null ) {
				themeMode = localStorage.getItem("data-bs-theme");
			} else {
				themeMode = defaultThemeMode;
			}
		}
		if (themeMode === "system") {
			themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
		}
		document.documentElement.setAttribute("data-bs-theme", themeMode);
	}
</script>
{{- end }}

{{- define "commonjs"}}
<script type="text/javascript" {{- if .}} nonce="{{.}}"{{- end}}>
    window.addEventListener("pageshow", function (event) {
        if (event.persisted) {
			let loadings = document.querySelectorAll('[data-kt-indicator=on]');
            if (loadings){
				[].forEach.call(loadings, function (loading) {
					loading.removeAttribute('data-kt-indicator');
					loading.disabled = false;
				});
            }
		}
	});
</script>
{{- end}}

{{- define "basejs"}}
<script type="text/javascript" {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}}>
    // https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode
    function escapeHTML(str) {
        var div = document.createElement('div');
        div.appendChild(document.createTextNode(str));
        return div.innerHTML;
    }

    function fileSizeIEC(a,b,c,d,e){
        return (b=Math,c=b.log,d=1024,e=c(a)/c(d)|0,a/b.pow(d,e)).toFixed(1)
            +' '+(e?'KMGTPEZY'[--e]+'iB':'Bytes')
    }

    function humanizeSpeed(a,b,c,d,e){
        return (b=Math,c=b.log,d=1024,e=c(a)/c(d)|0,a/b.pow(d,e)).toFixed(1)
            +' '+(e?'KMGTPEZY'[--e]+'B/s':'Bytes/s')
    }

    function initRepeaterItems() {
        let repeaterDeleteButtons = document.querySelectorAll('[data-repeater-delete]');
        let repeaterCreateButtons = document.querySelectorAll('[data-repeater-create]');

        repeaterDeleteButtons.forEach(d => {
            d.addEventListener("click", function(e){
                e.preventDefault();
            });
        });

        repeaterCreateButtons.forEach(d => {
            d.addEventListener("click", function(e){
                e.preventDefault();
            });
        });
    }

    function initRepeater(selector) {
        $(selector).repeater({
            initEmpty: false,

            show: function () {
                $(this).find('.select-repetear').each(function(){
                    initializeSelect2El(this);
                    let el = $(this);
                    if (el.hasClass('select-first')){
                        let firstVal = el.find("option:first-child").val();
                        el.val(firstVal).trigger('change');
                    }
                });
                $(this).localize();
                $(this).slideDown();
                $(this).find('[data-repeater-delete]').on("click", function(e){
                    e.preventDefault();
                });
            },

            hide: function (deleteElement) {
                $(this).slideUp(deleteElement);
            }
        });

        $(selector).find('.select-repetear').each(function(){
            initializeSelect2El(this);
        });
    }

    function clearChilds(el) {
        while (el.firstChild) {
            el.removeChild(el.firstChild);
        }
    }

    function initializeSelect2El(element) {
        if (element.getAttribute("data-kt-initialized") === "1") {
            return;
        }
        let options = {
            dir: document.body.getAttribute('direction'),
            language: {
                noResults: function () {
                    return $.t('select2.no_results');
                },
                searching: function () {
                    return $.t('select2.searching');
                },
                removeAllItems: function () {
                    return $.t('select2.removeall');
                },
                removeItem: function () {
                    return $.t('select2.remove');
                },
                search: function() {
                    return $.t('general.search');
                }
            }
        };

        if (element.getAttribute('data-hide-search') == 'true') {
            options.minimumResultsForSearch = Infinity;
        }

        $(element).select2(options);
        element.setAttribute("data-kt-initialized", "1");
    }

    const lngs = {
        en: { nativeName: 'English' },
        it: { nativeName: 'Italiano' }
    };

    const renderI18n = () => {
        document.documentElement.setAttribute('lang', i18next.resolvedLanguage);
        $('title').text('{{.Branding.Name}} - '+$.t('{{.Title}}'));
        $('body').localize();
        let select2elements = [].slice.call(document.querySelectorAll('[data-control="i18n-select2"]'));
        select2elements.map(function (element){
            initializeSelect2El(element);
        });
    }

    function initLocalizer() {
        i18next
            .use(i18nextChainedBackend)
            .use(i18nextBrowserLanguageDetector)
            .init({
                debug: false,
                supportedLngs: Object.keys(lngs),
                fallbackLng: 'en',
                load: 'languageOnly',
                backend: {
                    backends: [
                        i18nextLocalStorageBackend,
                        i18nextHttpBackend
                    ],
                    backendOptions: [{
                        expirationTime: 7 * 24 * 60 * 60 * 1000, // 7 days
                        defaultVersion: '{{.Version}}'
                    }, {
                        loadPath: '{{.StaticURL}}/locales/{{"{{lng}}"}}/{{"{{ns}}"}}.json?_='+new Date().getTime().toString()
                    }
                    ]
                }
            }, (err, t) => {
                if (err) {
                    console.error(err);
                } else {
                    jqueryI18next.init(i18next, $, { useOptionsAttr: true });

                    var languageSwitcher = $('#languageSwitcher');
                    if (languageSwitcher){
                        Object.keys(lngs).map((lng) => {
                            const opt = new Option(lngs[lng].nativeName, lng);
                            if (lng === i18next.resolvedLanguage) {
                                opt.setAttribute("selected", "selected");
                            }
                            languageSwitcher.append(opt);
                        });
                        languageSwitcher.on('change', function(){
                            const chosenLng = $(this).find("option:selected").attr('value');
                            i18next.changeLanguage(chosenLng, () => {
                                renderI18n();
                            });
                        });
                    }

                    renderI18n();
                    $.event.trigger({
                        type: "i18nload"
                    });
                }
                $('#app_loader').addClass("d-none");
                $('#app_root').removeClass("d-none");
                $.event.trigger({
                    type: "i18nshow"
                });
            });
    }

    function setI18NData(el, value, options) {
        el.removeAttr("data-i18n-options");
        el.attr("data-i18n", value);
        el.localize(options);
    }

    function handlePasswordInputVisibility(el) {
		let pwdVisibility = $(el.querySelector('[data-password-control="visibility"]'));
		let passwordInput = el.querySelector('[data-password-control="input"]');
        pwdVisibility.off("click");
		pwdVisibility.on('click', function(){
			let visibleIcon = this.querySelector(':scope > i:not(.d-none)');
            let hiddenIcon = this.querySelector(':scope > i.d-none');
            visibleIcon.classList.add('d-none');
            hiddenIcon.classList.remove('d-none');
            if (passwordInput){
				if (passwordInput.getAttribute('type').toLowerCase() === 'password' ) {
            		passwordInput.setAttribute('type', 'text');
        		} else {
            		passwordInput.setAttribute('type', 'password');
        		}
				passwordInput.focus();
			}
		});
	}

    function getCurrentURI(){
        let port = window.location.port;
        if (port){
            return window.location.protocol+"//"+window.location.hostname+":"+port;
        }
        return window.location.protocol+"//"+window.location.hostname;
    }

    function onFilesystemChanged(val){
        const supportedFs = ["local", "s3", "gcs", "azblob", "crypt", "sftp", "http"];
        let fsName = "local";
        switch (val){
            case '1':
                fsName = "s3";
                break;
            case '2':
                fsName = "gcs";
                break;
            case '3':
                fsName = "azblob";
                break;
            case '4':
                fsName = "crypt";
                break;
            case '5':
                fsName = "sftp";
                break;
            case '6':
                fsName = "http";
                break;
        }
        for (let i = 0; i < supportedFs.length; i++){
            if (supportedFs[i] == fsName){
                $('.form-group.fsconfig-'+fsName).show();
            } else {
                $('.form-group.fsconfig-'+supportedFs[i]).hide();
            }
        }
    }

    KTUtil.onDOMContentLoaded(function () {
        var dismissErrorBtn = $('#id_dismiss_error_msg');
        if (dismissErrorBtn){
            dismissErrorBtn.on("click", function(){
                $('#errorMsg').addClass("d-none");
            });
        }

        var logoutBtn = $('#id_logout_link');
        if (logoutBtn){
            logoutBtn.on("click", function(){
                doLogout();
            });
        }

        document.querySelectorAll('[data-password-control="container"]').forEach(el => {
			handlePasswordInputVisibility(el);
		});

        initLocalizer();
	});
</script>
{{- end}}

{{- define "globalstyle"}}
<style {{- if .}} nonce="{{.}}"{{- end}}>
    .text-sidebar {
		color: var(--bs-white);
	}

	[data-bs-theme="dark"] .text-sidebar {
		color: var(--bs-white);
    }

    .wrap-word {
        overflow-wrap: break-word;
    }

    .line-through {
        text-decoration: line-through;
    }

    .section-title {
        color: var(--bs-text-gray-800);
        font-weight: 600 !important;
        font-size: 1.45rem !important;
    }

    .section-title-inner {
        color: var(--bs-text-gray-800);
        font-weight: 600 !important;
        font-size: 1.3rem !important;
    }

    .readonly-input {
        color: var(--bs-text-gray-800);
        font-weight: 500 !important;
        font-size: 1.1rem !important;
    }

    .shortcut {
        font-family: monospace; color: #666;
    }

    .overflow-auto {
        overflow: auto;
    }
    .visibility-auto {
        content-visibility: auto;
    }
</style>
{{- end}}

{{- define "fonts"}}
<style {{- if .}} nonce="{{.CSPNonce}}"{{- end}}>
    /* cyrillic-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 300;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2) format('woff2');
        unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
    }

    /* cyrillic */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 300;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2) format('woff2');
        unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
    }

    /* greek-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 300;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2) format('woff2');
        unicode-range: U+1F00-1FFF;
    }

    /* greek */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 300;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2) format('woff2');
        unicode-range: U+0370-03FF;
    }

    /* vietnamese */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 300;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2) format('woff2');
        unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
    }

    /* latin-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 300;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2) format('woff2');
        unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
    }

    /* latin */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 300;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2) format('woff2');
        unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    }

    /* cyrillic-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 400;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2) format('woff2');
        unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
    }

    /* cyrillic */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 400;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2) format('woff2');
        unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
    }

    /* greek-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 400;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2) format('woff2');
        unicode-range: U+1F00-1FFF;
    }

    /* greek */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 400;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2) format('woff2');
        unicode-range: U+0370-03FF;
    }

    /* vietnamese */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 400;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2) format('woff2');
        unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
    }

    /* latin-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 400;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2) format('woff2');
        unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
    }

    /* latin */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 400;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2) format('woff2');
        unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    }

    /* cyrillic-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 500;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2) format('woff2');
        unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
    }

    /* cyrillic */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 500;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2) format('woff2');
        unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
    }

    /* greek-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 500;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2) format('woff2');
        unicode-range: U+1F00-1FFF;
    }

    /* greek */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 500;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2) format('woff2');
        unicode-range: U+0370-03FF;
    }

    /* vietnamese */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 500;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2) format('woff2');
        unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
    }

    /* latin-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 500;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2) format('woff2');
        unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
    }

    /* latin */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 500;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2) format('woff2');
        unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    }

    /* cyrillic-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 600;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2) format('woff2');
        unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
    }

    /* cyrillic */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 600;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2) format('woff2');
        unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
    }

    /* greek-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 600;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2) format('woff2');
        unicode-range: U+1F00-1FFF;
    }

    /* greek */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 600;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2) format('woff2');
        unicode-range: U+0370-03FF;
    }

    /* vietnamese */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 600;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2) format('woff2');
        unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
    }

    /* latin-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 600;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2) format('woff2');
        unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
    }

    /* latin */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 600;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2) format('woff2');
        unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    }

    /* cyrillic-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 700;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2) format('woff2');
        unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
    }

    /* cyrillic */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 700;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2) format('woff2');
        unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
    }

    /* greek-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 700;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2) format('woff2');
        unicode-range: U+1F00-1FFF;
    }

    /* greek */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 700;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2) format('woff2');
        unicode-range: U+0370-03FF;
    }

    /* vietnamese */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 700;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2) format('woff2');
        unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
    }

    /* latin-ext */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 700;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2) format('woff2');
        unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
    }

    /* latin */
    @font-face {
        font-family: 'Inter';
        font-style: normal;
        font-weight: 700;
        src: url({{.StaticURL}}/vendor/fonts/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2) format('woff2');
        unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    }
</style>
{{- end}}

{{- define "theme-switcher"}}
<div class="d-flex align-items-center ms-2 ms-lg-3">
    <a href="#" class="btn btn-icon btn-active-light-primary w-35px h-35px w-md-40px h-md-40px" data-kt-menu-trigger="{default:'click', lg: 'hover'}" data-kt-menu-attach="parent" data-kt-menu-placement="bottom-end">
        <i class="ki-duotone ki-night-day theme-light-show fs-2">
            <span class="path1"></span>
            <span class="path2"></span>
            <span class="path3"></span>
            <span class="path4"></span>
            <span class="path5"></span>
            <span class="path6"></span>
            <span class="path7"></span>
            <span class="path8"></span>
            <span class="path9"></span>
            <span class="path10"></span>
        </i>
        <i class="ki-duotone ki-moon theme-dark-show fs-2">
            <span class="path1"></span>
            <span class="path2"></span>
        </i>
    </a>
    <div class="menu menu-sub menu-sub-dropdown menu-column menu-rounded menu-title-gray-700 menu-icon-gray-500 menu-active-bg menu-state-color fw-semibold py-4 fs-base w-150px" data-kt-menu="true" data-kt-element="theme-mode-menu">
        <div class="menu-item px-3 my-0">
            <a href="#" class="menu-link px-3 py-2" data-kt-element="mode" data-kt-value="light">
                <span class="menu-icon" data-kt-element="icon">
                    <i class="ki-duotone ki-night-day fs-2">
                        <span class="path1"></span>
                        <span class="path2"></span>
                        <span class="path3"></span>
                        <span class="path4"></span>
                        <span class="path5"></span>
                        <span class="path6"></span>
                        <span class="path7"></span>
                        <span class="path8"></span>
                        <span class="path9"></span>
                        <span class="path10"></span>
                    </i>
                </span>
                <span data-i18n="theme.light" class="menu-title">Light</span>
            </a>
        </div>
        <div class="menu-item px-3 my-0">
            <a href="#" class="menu-link px-3 py-2" data-kt-element="mode" data-kt-value="dark">
                <span class="menu-icon" data-kt-element="icon">
                    <i class="ki-duotone ki-moon fs-2">
                        <span class="path1"></span>
                        <span class="path2"></span>
                    </i>
                </span>
                <span data-i18n="theme.dark" class="menu-title">Dark</span>
            </a>
        </div>
        <div class="menu-item px-3 my-0">
            <a href="#" class="menu-link px-3 py-2" data-kt-element="mode" data-kt-value="system">
                <span class="menu-icon" data-kt-element="icon">
                    <i class="ki-duotone ki-screen fs-2">
                        <span class="path1"></span>
                        <span class="path2"></span>
                        <span class="path3"></span>
                        <span class="path4"></span>
                    </i>
                </span>
                <span data-i18n="theme.system" class="menu-title">System</span>
            </a>
        </div>
    </div>
</div>
{{- end}}

{{- define "infomsg"}}
<div class="notice d-flex bg-light-primary rounded border-primary border border-dashed p-4 mb-10">
    <div class="d-flex flex-stack flex-grow-1">
        <div class="fs-5 fw-semibold text-break text-wrap text-gray-800">
            <span data-i18n="{{.}}"></span>
        </div>
    </div>
</div>
{{- end}}

{{- define "infomsg-no-mb"}}
<div class="notice d-flex bg-light-primary rounded border-primary border border-dashed p-4">
    <div class="d-flex flex-stack flex-grow-1">
        <div class="fs-5 fw-semibold text-break text-wrap text-gray-800">
            <span data-i18n="{{.}}"></span>
        </div>
    </div>
</div>
{{- end}}

{{- define "base"}}
<!DOCTYPE html>
<html lang="en">
    <head>
        <title></title>
        <meta charset="utf-8" />
        <meta name="description" content="" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta name="robots" content="noindex">
        <link rel="icon" type="image/png" href="{{.StaticURL}}{{.Branding.FaviconPath}}" />
		{{- template "fonts" . }}
        {{- block "extra_css" .}}{{- end}}
        {{- range .Branding.DefaultCSS}}
        <link href="{{$.StaticURL}}{{.}}" rel="stylesheet" type="text/css">
        {{- end}}
        {{- template "globalstyle" .CSPNonce }}
        {{- range .Branding.ExtraCSS}}
        <link href="{{$.StaticURL}}{{.}}" rel="stylesheet" type="text/css">
        {{- end}}
        {{- template "commonjs" .CSPNonce }}
    </head>

    <body data-kt-app-header-fixed="true" data-kt-app-header-fixed-mobile="true" data-kt-app-toolbar-enabled="true" data-kt-app-sidebar-enabled="true" data-kt-app-sidebar-fixed="true" data-kt-app-sidebar-push-header="true" data-kt-app-sidebar-push-toolbar="true" data-kt-app-sidebar-push-footer="true"  class="app-default">
        {{- template "theme-setup" .CSPNonce }}
        <div id="app_loader" class="align-items-center text-center my-10">
            <span class="spinner-border w-15px h-15px text-muted align-middle me-2"></span>
        </div>
        <div class="d-flex flex-column flex-root app-root d-none" id="app_root">
            <div class="app-page  flex-column flex-column-fluid " id="kt_app_page">
                {{- if .LoggedUser.Username}}
                <div id="kt_app_header" class="app-header" data-kt-sticky="true" data-kt-sticky-activate="{default: true, lg: true}" data-kt-sticky-name="app-header-minimize" data-kt-sticky-offset="{default: '200px', lg: '300px'}" data-kt-sticky-animation="false">
                    <div class="app-container  container-fluid d-flex align-items-stretch flex-stack " id="kt_app_header_container">
                        <div class="d-flex align-items-center d-block d-lg-none ms-n3" title="Show sidebar menu">
                            <div class="btn btn-icon btn-color-gray-800 btn-active-color-primary w-35px h-35px me-1" id="kt_app_sidebar_mobile_toggle">
                                <i class="ki-duotone ki-abstract-14 fs-2">
                                    <span class="path1"></span>
                                    <span class="path2"></span>
                                </i>
                            </div>
                            <span>
                                <img alt="Logo" src="{{.StaticURL}}{{.Branding.LogoPath}}" class="h-30px" />
                            </span>
                        </div>
                        <div class="app-navbar flex-lg-grow-1" id="kt_app_header_navbar">
                            <div class="app-navbar-item d-flex align-items-center flex-lg-grow-1 me-2 me-lg-0">
                            </div>
                            <!-- <div class="d-flex align-self-center flex-center flex-shrink-0">
                            </div> -->
                            <div class="d-flex align-self-center flex-center flex-shrink-0">
                                {{- template "navitems" .}}
							</div>
                        </div>
                    </div>
                </div>
                {{- else if .IsLoggedToShare}}
                <div class="app-container container-fluid d-flex mt-5">
                    <div class="d-flex align-items-center d-block ms-3">
                        <img alt="Logo" src="{{.StaticURL}}{{.Branding.LogoPath}}" class="h-50px" />
                    </div>
                    <div class="flex-grow-1">
                        <div class="d-flex justify-content-end">
                            {{- template "navitems" .}}
                        </div>
                    </div>
                </div>
                {{- end}}
                <div class="{{- if .LoggedUser.Username}}app-wrapper{{- end}} flex-column flex-row-fluid " id="kt_app_wrapper">
                    {{- if .LoggedUser.Username}}
                    <!-- <div id="kt_app_toolbar" class="app-toolbar">
                        <div id="kt_app_toolbar_container" class="app-container  container-fluid d-flex flex-lg-column py-3 py-lg-6 ">

                        </div>
                    </div> -->
                    <div id="kt_app_sidebar" class="app-sidebar flex-column" data-kt-drawer="true" data-kt-drawer-name="app-sidebar" data-kt-drawer-activate="{default: true, lg: false}" data-kt-drawer-overlay="true" data-kt-drawer-width="300px" data-kt-drawer-direction="start" data-kt-drawer-toggle="#kt_app_sidebar_mobile_toggle">
                        <div class="app-sidebar-header flex-column mx-10 pt-8" id="kt_app_sidebar_header">
                            <div class="d-flex flex-stack d-none d-lg-flex mb-13">
                                <div class="app-sidebar-logo">
									<img alt="Logo" src="{{.StaticURL}}{{.Branding.LogoPath}}" class="h-40px app-sidebar-logo-default" />
									<span class="text-sidebar fs-4 fw-semibold ps-5">{{.Branding.ShortName}}</span>
								</div>
                            </div>
                        </div>
                        <div class="app-sidebar-navs flex-column-fluid pb-6" id="kt_app_sidebar_navs">
                            <div id="kt_app_sidebar_navs_wrappers" class="hover-scroll-y my-2 mx-4" data-kt-scroll="true" data-kt-scroll-activate="true" data-kt-scroll-height="auto" data-kt-scroll-dependencies="#kt_app_sidebar_header" data-kt-scroll-wrappers="#kt_app_sidebar_navs" data-kt-scroll-offset="5px">
                                <div id="#kt_app_sidebar_menu" data-kt-menu="true" data-kt-menu-expand="false" class="menu menu-column menu-rounded menu-sub-indention menu-active-bg mb-7">
                                    {{- template "sidebaritems" .}}
                                </div>
                            </div>
                        </div>
                    </div>
                    {{- end}}
                    <div class="app-main flex-column flex-row-fluid " id="kt_app_main">
                        <div class="d-flex flex-column flex-column-fluid">
                            <div id="kt_app_content" class="app-content flex-column-fluid">
                                <div id="kt_app_content_container" class="app-container container-fluid">
                                    {{- template "page_body" .}}
                                </div>
                            </div>
                        </div>
                        {{- if .LoggedUser.Username}}
                        <div id="kt_app_footer" class="app-footer">
                            <div class="app-container  container-fluid d-flex flex-column flex-md-row flex-center flex-md-stack py-3 align-items-center justify-content-center">
                                <div class="text-gray-900 order-2 order-md-1">
                                    <span class="text-gray-700 fw-semibold me-1">{{.Version}}</span>
                                </div>
                            </div>
                        </div>
                        {{- end}}
                    </div>
                </div>
            </div>
        </div>
        <div id="kt_scrolltop" class="scrolltop" data-kt-scrolltop="true">
            <i class="ki-duotone ki-arrow-up">
                <span class="path1"></span>
                <span class="path2"></span>
            </i>
        </div>
        <div class="page-loader flex-column">
			<span class="spinner-border text-primary" role="status"></span>
			<span id="loading_message" class="text-muted fs-4 fw-semibold mt-5"></span>
		</div>

        <div class="modal fade" tabindex="-1" id="modal_alert">
            <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                    <div class="modal-body">
                        <div class="d-flex flex-center flex-column">
                            <span id="modal_alert_icon">
                            </span>
                            <div class="mt-10 text-center">
                                <span id="modal_alert_text" class="fs-6 text-gray-900 fw-semibold"></span>
                            </div>
                        </div>
                        <div id="modal_alert_items" class="d-flex flex-column mt-5 d-none">
                        </div>
                    </div>
                    <div class="modal-footer border-0 justify-content-center">
                        <button id="modal_alert_cancel" type="button" class="btn btn-secondary m-2"></button>
                        <button id="modal_alert_ok" type="button" class="btn btn-primary m-2"></button>
                    </div>
                </div>
            </div>
        </div>

        <div class="toast-container position-fixed top-0 end-0 p-3">
            <div id="toast_container" class="toast" role="alert" aria-live="assertive" aria-atomic="true" data-bs-autohide="false">
                <div class="toast-body border-0 d-flex align-items-center">
                    <span id="toast_icon"></span>
                    <span id="toast_msg" class="fs-5 fw-semibold text-gray-800 me-auto"></span>
                    <button data-i18n="[aria-label]general.close" type="button" class="btn btn-icon btn-sm btn-active-light-primary position-absolute position-sm-relative m-2 m-sm-0 top-0 end-0 ms-sm-auto" data-bs-dismiss="toast" aria-label="Close">
                        <i class="ki-solid ki-cross fs-2x text-gray-700"></i>
                    </button>
                </div>
            </div>
        </div>

        {{- block "modals" .}}{{- end}}
		<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/assets/plugins/global/plugins.bundle.js"></script>
		<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/assets/js/scripts.bundle.js"></script>
        <script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18next.min.js"></script>
		<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/jquery-i18next.min.js"></script>
		<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextBrowserLanguageDetector.min.js"></script>
		<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextChainedBackend.min.js"></script>
        <script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextLocalStorageBackend.min.js"></script>
        <script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/vendor/i18next/i18nextHttpBackend.min.js"></script>
		{{- template "basejs" . }}
        <script type="text/javascript" {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}}>
            var ModalAlert = function () {
                var modal;
                var promiseResolve;
                var isResolved;

                function resolvePromise(result) {
                    if (!isResolved) {
                        isResolved = true;
                        promiseResolve({
                            isConfirmed: result
                        });
                    }
                }

                var cancelFn = function() {
                    resolvePromise(false);
                    modal.hide();
                }

                var okFn = function() {
                    resolvePromise(true);
                    modal.hide();
                }

                var hideFn = function() {
                    resolvePromise(false);
                }

                return {
                    fire: function (params) {
                        modal = new bootstrap.Modal('#modal_alert');
                        let modalEl = $('#modal_alert');
                        let okBtn = $("#modal_alert_ok");
                        let cancelBtn = $("#modal_alert_cancel");
                        let itemsList = $('#modal_alert_items');

                        modalEl.off('hide.bs.modal');
                        modalEl.on('hide.bs.modal', hideFn);
                        cancelBtn.off("click");
                        okBtn.off("click");
                        cancelBtn.on("click", cancelFn);
                        okBtn.on("click", okFn);
                        okBtn.removeClass();
                        okBtn.addClass(params.customClass.confirmButton);
                        okBtn.addClass("m-2");
                        okBtn.text(params.confirmButtonText);
                        if (params.cancelButtonText){
                            cancelBtn.text(params.cancelButtonText);
                            cancelBtn.removeClass();
                            cancelBtn.addClass(params.customClass.cancelButton);
                            cancelBtn.addClass("m-2");
                        } else {
                            cancelBtn.addClass("d-none");
                        }

                        $("#modal_alert_text").text(params.text);
                        itemsList.empty();
                        itemsList.addClass("d-none");
                        if (params.items && params.items.length > 0){
                            itemsList.removeClass("d-none");
                            $.each(params.items, function(key, item) {
                                itemText = escapeHTML(item);
                                itemsList.append(`<li class="d-flex align-items-center py-2 fw-bold fs-6 text-gray-800"><span class="bullet bullet-dot bg-primary me-2"></span>${itemText}</li>`);
                            });
                        }

                        switch (params.icon){
                            case "warning":
                                $("#modal_alert_icon").html(`<i class="ki-duotone ki-information-5 fs-5x text-danger">
                                                                <span class="path1"></span>
                                                                <span class="path2"></span>
                                                                <span class="path3"></span>
                                                            </i>`);
                                break;
                            case "success":
                                $("#modal_alert_icon").html(`<i class="ki-duotone ki-check-square fs-5x text-success">
                                                                <span class="path1"></span>
                                                                <span class="path2"></span>
                                                            </i>`);
                                break;
                            default:
                                $("#modal_alert_icon").html(`<i class="ki-duotone ki-question-2 fs-5x text-primary">
                                                                <span class="path1"></span>
                                                                <span class="path2"></span>
                                                                <span class="path3"></span>
                                                            </i>`);
                        }

                        return new Promise(function(resolve, reject) {
                            promiseResolve = resolve;
                            isResolved = false;
                            modal.show();
                        });
                    }
                }
            }();

            function showToast(status, msg, options) {
                const toast = bootstrap.Toast.getOrCreateInstance(document.getElementById('toast_container'));
                if (status === 1){
                    $("#toast_icon").html(`<i class="ki-duotone ki-check-square fs-3x text-success me-5">
                                            <span class="path1"></span>
                                            <span class="path2"></span>
                                        </i>`);
                } else {
                    $("#toast_icon").html(`<i class="ki-duotone ki-information-5 fs-3x text-warning me-5">
                                            <span class="path1"></span>
                                            <span class="path2"></span>
                                            <span class="path3"></span>
                                        </i>`);
                }
                setI18NData($('#toast_msg'), msg, options)
                toast.show();
            }

            function doLogout() {
                ModalAlert.fire({
                    text: $.t("general.confirm_logout"),
                    icon: "question",
                    confirmButtonText: $.t("login.signout"),
                    cancelButtonText: $.t("general.cancel"),
                    customClass: {
                        confirmButton: "btn btn-primary",
                        cancelButton: 'btn btn-secondary'
                    }
                }).then((result) =>{
                    if (result.isConfirmed){
                        window.location.replace('{{.LogoutURL}}');
                    }
                });
            }
        </script>
		{{- block "extra_js" .}}{{- end}}
    </body>
</html>
{{- end}}